﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Base;


public partial class Member_Know_KnowProblemsList : nspBase.MemberBasePge
{
    protected string Rewrite = "", WebUrl = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckCookies())
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }
        else
            Response.Redirect("../../login/login.aspx");
        WebUrl = Base.BasePage.Config.WebURL;
        Rewrite = Base.BasePage.Config.Rewrite;
    }
    private void Bind()
    {
        string strURl = Request.RawUrl;
        strURl = strURl.Substring(0, strURl.IndexOf(".aspx")) + ".aspx";
        PageNo1.Strurl = strURl;
        PageNo1.Table = "W_KnowProblems";
        PageNo1.FldName = "AddDate";
        PageNo1.StrGetFields = "ID,Caption,Verify,State,AnswerCount,AddDate,UserName";
        PageNo1.PageSize = 12;
        string strWhere = "UserID=" + GetCookie("UserID");
        if (Request.QueryString["page"] != "" && Request.QueryString["page"] != null)
        {
            PageNo1.Pageindex = Convert.ToInt32(Request.QueryString["page"].ToString());
            if (Session["strWhere"] != null)
                strWhere = Session["strWhere"].ToString();
            PageNo1.Where = strWhere;
            DataTable dt = PageNo1.BindViewDesc();
            if (dt.DefaultView.Count == 0)
            {
                lblMessage.Visible = true;
                lblMessage.Text = "暂无数据信息";
            }
            else
                lblMessage.Visible = false;
            grdProblem.DataSource = dt.DefaultView;
            grdProblem.DataBind();
        }
        else
        {
            if (GetRequest.GetQueryStringValue("V") != "")
            {
                switch (GetRequest.GetQueryStringValue("v"))
                {
                    case "1":
                        strWhere += " and W_KnowProblems.State=1";
                        break;
                    case "0":
                        strWhere += " and W_KnowProblems.State=0";
                        break;
                    default:
                        break;
                }
            }
            PageNo1.Where = strWhere;
            PageNo1.Pageindex = 1;
            Session["strWhere"] = strWhere;
            DataTable dt = PageNo1.BindViewDesc();
            if (dt.DefaultView.Count == 0)
            {
                lblMessage.Visible = true;
                lblMessage.Text = "暂无数据信息";
            }
            else
                lblMessage.Visible = false;
            grdProblem.DataSource = dt.DefaultView;
            grdProblem.DataBind();
        }
        SetColor();
    }
    private void SetColor()
    {
        if (Request.QueryString["v"] != null)
        {
            if (Request.QueryString["v"] == "1")
                this.menu2.Attributes.Add("class", "MenuLiCheck");
            else
                this.menu3.Attributes.Add("class", "MenuLiCheck");
        }
        else
            this.menu1.Attributes.Add("class", "MenuLiCheck");
    }
}
